// 重置样式
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

#app {
  height: 100%;
  width: 100%;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--el-text-color-primary);
  background-color: var(--el-bg-color-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  word-wrap: break-word;
  word-break: break-word;
}

// 链接样式
a {
  color: var(--el-color-primary);
  text-decoration: none;
  
  &:hover {
    color: var(--el-color-primary-light-3);
  }
}

// 全局过渡动画
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

// 工具类
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mr-8 {
  margin-right: 8px;
}

.mr-16 {
  margin-right: 16px;
}

// 暗色主题变量
.dark {
  --trading-profit-color: #52c41a;
  --trading-loss-color: #f5222d;
  --trading-bg-color: #1f1f1f;
  --trading-border-color: #303030;
}

// 亮色主题变量
:root {
  --trading-profit-color: #52c41a;
  --trading-loss-color: #f5222d;
  --trading-bg-color: #ffffff;
  --trading-border-color: #e8e8e8;
}

// 交易相关样式
.profit {
  color: var(--trading-profit-color);
}

.loss {
  color: var(--trading-loss-color);
}

.trading-card {
  background: var(--trading-bg-color);
  border: 1px solid var(--trading-border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

// 滚动条美化
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--el-bg-color-page);
}

::-webkit-scrollbar-thumb {
  background: var(--el-border-color-light);
  border-radius: 3px;
  
  &:hover {
    background: var(--el-border-color);
  }
}

// Element Plus 组件样式优化
.el-card {
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  border: none;
  
  &.is-hover-shadow:hover {
    box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.15);
  }
}

.el-table {
  .el-table__header {
    th {
      background-color: var(--el-bg-color-page);
      font-weight: 600;
    }
  }
}

// 响应式布局工具类
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (max-width: 1400px) {
  .container {
    max-width: 1140px;
  }
}

@media (max-width: 1200px) {
  .container {
    max-width: 960px;
    padding: 0 12px;
  }
}

@media (max-width: 992px) {
  .container {
    max-width: 720px;
    padding: 0 8px;
  }
}

@media (max-width: 768px) {
  .container {
    max-width: 540px;
    padding: 0 8px;
  }
  
  .mobile-hidden {
    display: none !important;
  }
}

@media (max-width: 576px) {
  .container {
    padding: 0 4px;
  }
}

@media (min-width: 769px) {
  .desktop-hidden {
    display: none !important;
  }
}

// 通用动画
.bounce-enter-active {
  animation: bounce-in 0.5s;
}

.bounce-leave-active {
  animation: bounce-in 0.5s reverse;
}

@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

  .trading-stream-section {
    margin-bottom: 24px;
    width: 100%;

    .realtime-trading-card {
      height: 500px;
      display: flex;
      flex-direction: column;
      width: 100%;

    .realtime-header {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .header-left {
        display: flex;
        align-items: center;
        gap: 12px;

        .header-title {
          display: flex;
          align-items: center;
          font-weight: 600;

          .realtime-icon {
            margin-right: 8px;
            color: var(--el-color-primary);
          }
        }

        .live-tag {
          animation: pulse 2s infinite;

          .el-icon {
            margin-right: 4px;
          }
        }
      }

      .header-actions {
        display: flex;
        gap: 8px;
      }
    }

    .realtime-trading-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      height: 100%;

              .trading-stream {
          flex: 1;
          overflow-y: auto;
          padding: 0;
          max-height: 350px;

          .trade-header {
            display: grid;
            grid-template-columns: 90px 120px 80px 140px 100px 120px 90px 50px;
            align-items: center;
            padding: 12px 16px;
            background-color: var(--el-bg-color-page);
            border-bottom: 2px solid var(--el-border-color);
            font-weight: 600;
            font-size: 12px;
            color: var(--el-text-color-secondary);
            gap: 8px;
            position: sticky;
            top: 0;
            z-index: 10;

            div {
              text-align: left;
            }

            .header-amount,
            .header-price,
            .header-pnl {
              text-align: right;
            }

            .header-status {
              text-align: center;
            }
          }

          .trade-item {
            display: grid;
            grid-template-columns: 90px 120px 80px 140px 100px 120px 90px 50px;
            align-items: center;
            padding: 12px 16px;
            border-bottom: 1px solid var(--el-border-color-lighter);
            transition: all 0.3s ease;
            font-size: 13px;
            gap: 8px;

          &:hover {
            background-color: var(--el-bg-color-page);
          }

          &:last-child {
            border-bottom: none;
          }

          .trade-time {
            font-weight: 500;
            color: var(--el-text-color-secondary);
          }

          .trade-symbol {
            font-weight: 600;
            color: var(--el-text-color-primary);
          }

          .trade-strategy {
            color: var(--el-text-color-regular);
            font-size: 12px;
          }

          .trade-amount {
            font-family: 'Monaco', 'Menlo', monospace;
            text-align: right;
          }

          .trade-price {
            font-family: 'Monaco', 'Menlo', monospace;
            text-align: right;
            font-weight: 500;
          }

          .trade-pnl {
            text-align: right;
            font-weight: 600;
            font-family: 'Monaco', 'Menlo', monospace;

            .profit {
              color: var(--el-color-success);
            }

            .loss {
              color: var(--el-color-danger);
            }
          }

          .trade-status {
            text-align: center;

            .status-icon {
              color: var(--el-color-success);
            }
          }

          &.new-trade {
            background-color: var(--el-color-primary-light-9);
            animation: newTradeHighlight 2s ease-out;
          }

          &.trade-buy {
            border-left: 3px solid var(--el-color-success);
          }

          &.trade-sell {
            border-left: 3px solid var(--el-color-primary);
          }

          &.trade-stop {
            border-left: 3px solid var(--el-color-danger);
          }
        }
      }

      .trading-summary {
        padding: 20px;
        background-color: var(--el-bg-color-page);
        border-top: 1px solid var(--el-border-color-lighter);
        display: flex;
        justify-content: space-between;
        gap: 24px;

        .summary-item {
          text-align: center;
          flex: 1;
          padding: 0 16px;

          .summary-label {
            font-size: 13px;
            color: var(--el-text-color-secondary);
            display: block;
            margin-bottom: 6px;
            font-weight: 500;
          }

          .summary-value {
            font-weight: 600;
            font-size: 18px;
            font-family: 'Monaco', 'Menlo', monospace;
            line-height: 1.2;

            &.profit {
              color: var(--el-color-success);
            }
          }
        }
      }
    }
  }

  .strategy-section {
    margin-bottom: 24px;
    width: 100%;

    .strategy-status-card {
      width: 100%;
      
      :deep(.el-card__body) {
        padding: 20px;
      }
    }
  }

  // 图表样式
  .chart-section {
    margin-bottom: 24px;
    width: 100%;

    .chart-card {
      .chart-container {
        display: flex;
        flex-direction: column;
        height: 300px;

        .chart-y-axis {
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          position: absolute;
          left: 0;
          top: 0;
          bottom: 40px;
          width: 80px;
          padding: 20px 0;

          .y-label {
            font-size: 12px;
            color: var(--el-text-color-secondary);
            text-align: right;
            padding-right: 8px;
          }
        }

        .chart-area {
          flex: 1;
          margin: 20px 0 40px 80px;
          position: relative;
          background: linear-gradient(135deg, var(--el-color-primary-light-9) 0%, var(--el-color-success-light-9) 100%);
          border-radius: 8px;

          .chart-grid {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;

            .grid-line {
              position: absolute;
              
              &.horizontal {
                width: 100%;
                height: 1px;
                background: var(--el-border-color-lighter);
                
                &:nth-child(1) { top: 0%; }
                &:nth-child(2) { top: 25%; }
                &:nth-child(3) { top: 50%; }
                &:nth-child(4) { top: 75%; }
                &:nth-child(5) { top: 100%; }
              }
              
              &.vertical {
                height: 100%;
                width: 1px;
                background: var(--el-border-color-lighter);
                
                &:nth-child(6) { left: 0%; }
                &:nth-child(7) { left: 16.67%; }
                &:nth-child(8) { left: 33.33%; }
                &:nth-child(9) { left: 50%; }
                &:nth-child(10) { left: 66.67%; }
                &:nth-child(11) { left: 83.33%; }
                &:nth-child(12) { left: 100%; }
              }
            }
          }

          .chart-svg {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
          }
        }

        .chart-x-axis {
          display: flex;
          justify-content: space-between;
          margin-left: 80px;
          padding: 0 5px;

          .x-label {
            font-size: 12px;
            color: var(--el-text-color-secondary);
            text-align: center;
          }
        }

        .chart-tip {
          margin: 16px 0 0 0;
          font-size: 13px;
          color: var(--el-text-color-secondary);
          text-align: center;
        }
      }

      .chart-controls {
        display: flex;
        gap: 8px;
      }
    }
  }

  .actions-section {
    margin-bottom: 24px;
    width: 100%;

    .quick-actions-bar {
      background-color: var(--el-bg-color);
      border-radius: 8px;
      border: 1px solid var(--el-border-color-lighter);
      padding: 20px;

      .actions-title {
        margin: 0 0 16px 0;
        font-size: 16px;
        font-weight: 600;
        color: var(--el-text-color-primary);
      }

      .action-buttons {
        display: flex;
        gap: 16px;
        flex-wrap: wrap;

        .action-button {
          flex: 1;
          min-width: 200px;
          height: 48px;
          display: flex;
          align-items: center;
          justify-content: center;
          
          .el-icon {
            margin-right: 8px;
            font-size: 16px;
          }
        }
      }
    }
  }
}

  .strategy-status-card {
    width: 100%;
    
    .strategy-list {
      width: 100%;
      
      .strategy-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 0;
        border-bottom: 1px solid var(--el-border-color-lighter);
        width: 100%;

        &:last-child {
          border-bottom: none;
        }

      .strategy-info {
        .strategy-name {
          font-weight: 600;
          font-size: 14px;
          color: var(--el-text-color-primary);
          margin-bottom: 2px;
        }

        .strategy-type {
          font-size: 12px;
          color: var(--el-text-color-secondary);
        }
      }

              .strategy-status-badge {
          display: flex;
          flex-direction: column;
          align-items: flex-end;
          gap: 4px;
          min-width: 80px;

          .strategy-pnl {
            font-weight: 600;
            font-size: 12px;
            font-family: 'Monaco', 'Menlo', monospace;

            &.profit {
              color: var(--el-color-success);
            }

            &.loss {
              color: var(--el-color-danger);
            }
          }
        }
    }
  }
}



// 添加动画效果
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

@keyframes newTradeHighlight {
  0% {
    background-color: var(--el-color-primary-light-7);
    transform: scale(1.02);
  }
  100% {
    background-color: transparent;
    transform: scale(1);
  }
}

// 响应式优化
@media (max-width: 768px) {
  .trading-stream-section {
    .realtime-trading-card {
      height: auto !important;
    }
  }

  .strategy-section {
    margin-top: 16px;

    .strategy-status-card {
      height: auto !important;
    }
  }

  .actions-section {
    .quick-actions-bar {
      .action-buttons {
        flex-direction: column;
        
        .action-button {
          min-width: 100%;
        }
      }
    }
  }

  .trading-stream {
    .trade-header,
    .trade-item {
      font-size: 11px;
      padding: 8px 12px;
      grid-template-columns: 60px 80px 50px 100px 70px 80px 60px 30px;
      gap: 4px;
    }
  }
}

// 针对性修复样式问题
.dashboard {
  width: 100%;
  
  .trading-stream-section,
  .strategy-section,
  .actions-section {
    width: 100%;
    
    .el-row {
      margin: 0 !important;
      width: 100%;
    }
    
    .el-col {
      padding: 0 8px;
      
      &:last-child {
        padding-right: 0;
      }
      
      &:first-child {
        padding-left: 0;
      }
    }
  }
}